import 'dart:async';

import 'package:flutter_test/flutter_test.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:open_eye/business/find_page/model/Type_entity.dart';
import 'package:open_eye/http/apiservice/api_service.dart';
import 'package:open_eye/http/dio_client.dart';
import 'package:open_eye/http/result/base_result.dart';
import 'package:open_eye/http/result/base_wan_result.dart';

void main(){
  testApi();
}

void testApi(){
  RxList<TypeEntity> listdata = <TypeEntity>[].obs;
  test("test dio api",()  {
    Future<List<TypeEntity>> t =   ApiService().queryCategoryData();
    if (t is BaseResult) {
      baseResultHandler(t, false, (value){
        // if (value.isNotEmpty) {
        //   dataList.addAll(value);
        // }
        expect(value.toString(),isNotNull);

        print("打印"+value.toString());

      }, false);
    } else {
      expect(t.toString(),isNotNull);
      print("打印2"+t.toString());
    }
    // expect(listdata[0].toString(),isNotNull);
    // print("打印"+listdata[0].toString());
  });
}

void baseResultHandler<T>(t, bool handleSuccess,
    FutureOr<dynamic> Function(T value) onValue, bool handleError) {
  if ("1" == t.resCode) {
    if (handleSuccess) {
    }
    onValue(t);
  } else {
    if (handleError) {

    } else {
      onValue(t);
      if (handleSuccess) {

      }
    }
  }
}